<?php

function Tools_Dedecms_dedecms_Insert_Arc($sqlfile, $fromurl, $title, $body, $arcId, $categoryId, $kw = NULL, $desc = NULL) {
    if (!$kw) {
        $kw = $title;
    }
    if (!$desc) {
        $desc = mb_substr($body, 0, 30, 'UTF-8');
    }
    if (!file_exists($sqlfile)) {
        log::dw('No Such File:' . $sqlfile);
        fCheckDir($sqlfile);
    }
    $query1 = "INSERT INTO `dede_addonarticle` (`aid`,`typeid`,`body`,`redirecturl`,`templet`,`userip`) VALUES ('{$arcId}','{$categoryId}','{$body}','','','');" . PHP_EOL;
    file_put_contents($sqlfile, $query1, 8);

    $query2 = "INSERT INTO `dede_arctiny` (`id`,`typeid`,`typeid2`,`arcrank`,`channel`,`senddate`,`sortrank`,`mid`) VALUES ('{$arcId}','{$categoryId}','0',0,1,'" . time() . "','" . time() . "',1);" . PHP_EOL;
    file_put_contents($sqlfile, $query2, 8);

    $query3 = "INSERT INTO `dede_archives` (`id`,`typeid`,`typeid2`,`sortrank`,`flag`,`ismake`,`channel`,`arcrank`,`click`,`money`,`title`,`shorttitle`,`color`,`writer`,`source`,`litpic`,`pubdate`,`senddate`,`mid`,`keywords`,`lastpost`,`scores`,`goodpost`,`badpost`,`voteid`,`notpost`,`description`,`filename`,`dutyadmin`,`tackid`,`mtype`,`weight`,`fromurl`) VALUES ('{$arcId}','{$categoryId}','0','" . time() . "','',1,1,0,104,0,'{$title}','','','KingPHP','Spider','','" . time() . "','" . time() . "',1,'{$kw}',0,0,0,0,0,0,'{$desc}','',1,0,0,'{$arcId}','{$fromurl}');" . PHP_EOL;
    file_put_contents($sqlfile, $query3, 8);

    return $arcId;
}

?>